//
//  LSCompetitonDetailBaseViewController.m
//  LookScore
//
//  Created by wr on 2018/4/19.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSCompetitonDetailBaseViewController.h"
#import "LSTeamStandingsViewController.h"//球队战绩详情
#import "LSTeamHandicapViewController.h"//球队让球盘
#import "LSTeamSizeplateViewController.h"//球队大小盘
#import "LSTeamMatchViewController.h"//球队比赛
#import "LSTeamLineupViewController.h"//球队阵容
#import "LSPulldDownOptionsView.h"//下拉view
#import "ZJScrollPageView.h"

@interface LSCompetitonDetailBaseViewController ()<ZJScrollPageViewDelegate>

@property(strong, nonatomic)NSArray<NSString *> *titles;

@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;

@property (nonatomic, strong) ZJScrollPageView *scrollPageView;

@property(strong,nonatomic)UIButton *navigetionBu;

@property(strong,nonatomic)LSPulldDownOptionsView *pullView;


@end

@implementation LSCompetitonDetailBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addScrollerUI];
    
}
#pragma mark 🔥 Event

//-(void)chooseTimerEvent:(UIButton *)sender{
//
//    NSArray * dataArray = [self.leagueInfoDic[@"LeagueHistory"] componentsSeparatedByString:@","];
//
//    NSMutableArray *array = dataArray.mutableCopy;
//    if (!self.pullView) {
//        LSPulldDownOptionsView *pullView=[[LSPulldDownOptionsView alloc]initWithFrame:CGRectMake(0, 0, LSScreenWidth, LSScreenHeight) normalTitleColor:LSNavMainDarkColor selectedTitleColor:LSTitleWhiteColor normalBackViewColor:LSTitleWhiteColor selectedBackViewColor:LSNavMainDarkColor height:35];
//
//        pullView.modelArray=array.mutableCopy;
//        pullView.cellClickBlock = ^(NSInteger index) {
//            [self.navigetionBu setTitle:array[index] forState:UIControlStateNormal];
//        };
//        self.pullView=pullView;
//        [self.view addSubview:pullView];
//    }
//    self.pullView.hidden=NO;
//
//}





#pragma mark 🔥 scrollerUI <ZJScrollPageViewDelegate>
-(void)addScrollerUI{
//    NSArray *yearArray = [self.leagueInfoDic[@"LeagueHistory"] componentsSeparatedByString:@","];
//    UIButton *navigetionBu=[UIButton new];
//    [navigetionBu setTitleColor:LSNavTitlenColor forState:UIControlStateNormal];
//    [navigetionBu setTitle:yearArray.firstObject forState:UIControlStateNormal];
//    [navigetionBu setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    //    navigetionBu.titleEdgeInsets=UIEdgeInsetsMake(0,-50, 0, 50);
//    //    navigetionBu.imageEdgeInsets=UIEdgeInsetsMake(0, 60, 0, -60);
//    [navigetionBu addTarget:self action:@selector(chooseTimerEvent:) forControlEvents:UIControlEventTouchUpInside];
//    self.navigetionBu=navigetionBu;
//    self.navigationItem.titleView=navigetionBu;
//
//    UIButton *rightButton=[UIButton new];
//    [rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [rightButton setTitle:@"赛制" forState:UIControlStateNormal];
//    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:rightButton];
    
    self.title = @"皇家马德里";
    
    self.childVcs=[self setupChildVc];
    
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    
    style.scrollLineColor=LSNavMainColor;
    
    style.segmentHeight=35;
    
    style.autoAdjustTitlesWidth=YES;
    
    style.normalTitleColor=[UIColor colorWithRed:255.f/255.f green:255.f/255.f blue:255.f/255.f alpha:1];
    
    style.selectedTitleColor=LSNavTitlenColor;
    
    style.scrollLineColor=LSNavTitlenColor;
    
    self.titles = @[@"战绩", @"让球盘",@"大小盘",@"比赛", @"阵容"];
    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width,self.view.bounds.size.height) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    _scrollPageView.segmentView.backgroundColor=LSNavMainColor;
    [self.view addSubview:_scrollPageView];
}
- (NSArray *)setupChildVc {
//    NSString *leagueId = self.leagueInfoDic[@"LeagueId"];
//    NSString *year = [self.leagueInfoDic[@"LeagueHistory"] componentsSeparatedByString:@","].firstObject;
    
    LSTeamStandingsViewController *teamStandingsVC = [LSTeamStandingsViewController new];
    
    LSTeamHandicapViewController *teamHandicap = [LSTeamHandicapViewController new];
    
    LSTeamSizeplateViewController *teamSizeplateVC = [LSTeamSizeplateViewController new];
    
    LSTeamMatchViewController *teamMatchVC = [LSTeamMatchViewController new];
    
    LSTeamLineupViewController *teamLineupVC = [LSTeamLineupViewController new];
    
    NSArray *childVcs = [NSArray arrayWithObjects:teamStandingsVC,teamHandicap,teamSizeplateVC,teamMatchVC, teamLineupVC, nil];
    
    return childVcs;
}
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        childVc = self.childVcs[index];
    }
    
    return childVc;
}


- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

